<template>
	<view class="p30">
		<view class="flex fs26">
			<view class="flex1">
				<view class="">团队总人数 {{data.master_num}}</view>
			</view>
			<view class="flex1">
				<view class="">当前在线人数 {{data.online_num}}</view>
			</view>
			<view class="color-blue" @click="operate" v-if="['creator','leader'].includes(data.identity)">管理</view>
		</view>
		<view class="h20"></view>
		<masterUserList :list="list" />
		<view class="h120"></view>
		<view class="pf bottom0 left0 bg-fff w-max">
			<view class="flex">
				<view class="flex1 p20" v-if="['creator','leader'].includes(data.identity)">
					<u-button type="warning" ripple
						@click="$jump('/pages/my/team/search-user',{...$params,type:'search',tit:'添加人员'})">添加人员</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: '',
				list: [],

			};
		},
		onLoad() {
		},
		onShow() {
			this.getData()
			this.getList()
		},
		onReachBottom() {
			this.getList('down')
		},
		methods: {
			operate() {
				let list = [{
					name: '移除人员',
					fn: () => {
						this.$jump('/pages/my/team/search-user', {
							...this.$params,
							type: 'del',
							tit: '移除成员'
						})
					},
					show:['creator','leader'].includes(this.data.identity)
				}, {
					name: '设置管理员',
					fn: () => {
						this.$jump('/pages/my/team/search-user', {
							...this.$params,
							type: 'set',
							tit: '设置管理员'
						})
					},
					show:['creator',''].includes(this.data.identity)
				}]
				this.$tool.showActionSheet(list.filter(e=>e.show))
			},
			getData() {
				this.$request('/master/agency/agencyInfo', this.$params).then(res => {
					this.data = res.data
					uni.setNavigationBarTitle({
						title: res.data.name + ''
					})
				})
			},
			getList(e) {
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					...this.$params,
					page: this.page,
				}
				this.$request('/master/agency/agencyMaster', params).then(res => {
					let list = res.data.data
					e == 'down' ? this.list.push(...list) : this.list = list
				})
			},
		}
	}
</script>

<style lang="scss">

</style>